<template>

  <Scroll :list="ranklist" class="rank-scroll" ref="scroll">
    <div>
      <div v-for="item of ranklist" :key="item.topId" class="item" @click="selectRank(item)">
        <img v-lazy="item.picUrl">
        <ul>
          <li v-for="(list, index) of item.song" :key="index">
            {{ ++index }}. {{list.title}}
          </li>
        </ul>
      </div>
    </div>
  </Scroll>

</template>

<script>
import Scroll from 'components/base/Scroll'

import { playMixin } from 'common/js/mixin'
export default {
  mixins: [playMixin], // 组件同名方法可以覆盖mixin方法

  props: {
    ranklist: {
      type: Array
    }
  },
  components: {
    Scroll
  },
  methods: {
    selectRank(item) {
      // 给vuex进行传参
      this.$store.commit('setRank', item)
      this.$store.commit('setValue', '排行')
      this.$router.push('/rank/id=' + item.topId)
    },
    // 当有播放列表时候需要底部有一个高度
    handlePlayList() {
      const bottom = this.playList.length > 0 ? '60px' : ''
      this.$refs.scroll.$el.style.bottom = bottom
      this.$refs.scroll.refresh()
    }
  }
}
</script>

<style scoped lang="stylus">
.rank-scroll {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  overflow: hidden;
  padding: 0 20px;

  .item {
    display: flex;
    padding-bottom: 20px;
  }

  img {
    width: 100px;
    height: 100px;
  }

  ul {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 20px;
    height: 100px;
    overflow: hidden;
    background: #333;
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px;

    li {
      width: 100%;
      line-height: 26px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }
}
</style>
